#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H

#include <QWidget>

class GraphWidget : public QWidget
{
    Q_OBJECT

public:
    GraphWidget(QWidget *parent = 0);

public slots:
    void setData(double *data, int len);
    void reset();
    void left();
    void right();
    void zoomIn();
    void zoomOut();

protected:
    void paintEvent(QPaintEvent *event);

private:
    void recalc();
    void paintGraph(QPainter *painter);
    void paintLegend(QPainter *painter);

    inline int toVertPos(double y);


private:
    double *data;
    int dataLen;

    int displayStart, displayEnd;

    double dataMax, dataMin;

    double *lo, *hi;

    int graphX, graphY, graphWidth, graphHeight;

    static const int leftBorder = 50;
    static const int rightBorder = 5;
    static const int topBorder = 20;
    static const int bottomBorder = 30;
};

#endif // GRAPHWIDGET_H
